package com.demo.des;

import java.net.URLEncoder;

import org.ad.crypto.DesEcbUtil;
import org.ad.crypto.MD5Util;

import android.app.Activity;
import android.os.Bundle;

/**
 * 加密之后是可识别的字符串
 * 
 * @date 2013-8-28
 */
public class DES2MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		try {
			//待加密内容url
			System.out.println("DesEcbUtil");
			String str = "8888888800001234";
			String pwdKey = "12345678"; 
			String pwdKeyMD5 = MD5Util.encode(pwdKey);
			System.out.println("pwdKeyMD5：" + pwdKeyMD5);
			String encodeStr = DesEcbUtil.encode(pwdKeyMD5, str);
			String decodeStr = DesEcbUtil.decodeValue(pwdKeyMD5, encodeStr);
			System.out.println("加密前的字符串：" + str);
			System.out.println("加密后的字符串：" + encodeStr);
			System.out.println("解密后的字符串：" + decodeStr);
			System.out.println("DesEcbUtil");
			
			// URL转义
			final String encodedURL = URLEncoder.encode(encodeStr, "UTF-8");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
}
